package memberlayer

import (
    //"errors"
	//"dhfshop/models/member"
)

/*
// 增加经验值
func (m *memberImpl) AddExp(exp int32) error {
	m.value.Exp += exp
	_, err := m.Save()
	//判断是否升级
	m.checkLevelUp()
	return err
}


// 检查升级
func (m *memberImpl) checkLevelUp() bool {
	lg := m.manager.LevelManager()
	levelId := lg.GetLevelIdByExp(m.value.Exp)
	if levelId == 0 {
		return false
	}
	// 判断是否大于当前等级
	if m.value.Level > levelId {
		return false
	}
	// 判断等级是否启用
	lv := lg.GetLevelById(levelId)
	if lv.Enabled == 0 {
		return false
	}
	origin := m.value.Level
	unix := time.Now().UTC().Unix()
	m.value.Level = levelId
	m.value.UpdateTime = unix
	_, err := m.Save()
	if err == nil {
		m.level = nil
		lvLog := &member.LevelUpLog{
			MemberId:    m.GetAggregateRootId(),
			OriginLevel: origin,
			TargetLevel: levelId,
			IsFree:      1,
			PaymentId:   0,
			Reviewed:    enum.ReviewConfirm,
			CreateTime:  unix,
		}
		_, err = m.rep.SaveLevelUpLog(lvLog)
	}
	return true
}
*/

